﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace smx
{
    /// <summary>
    /// this class will deal with generating the primary keys for the components table initially
    /// this may come in useful in other projects as well as we progress, idea from fusion software's 
    /// lee ottaway
    /// </summary>
    class keyGen
    {


        public long generateId()
        {
            long id = 0;
            string random = generateRandom();
            string gen = "1" + DateTime.Now.ToString("ddMMyymm") + random;
            id = Convert.ToInt64(gen);
            return id;
        }

        //----------------------------------------------------------------------------------------------------------------------------
        //get a 6 digit random number
        //----------------------------------------------------------------------------------------------------------------------------
        private string generateRandom()
        {
            Random ran = new Random();

            int ran1 = ran.Next(1, 9);
            int ran2 = ran.Next(1, 9);
            string digit = ran1.ToString() + ran2.ToString();
            return digit;
        }
    }
}
